/**
 * pathCanvasProvider
 */

 function pathCanvasProvider($element, dataProvider, navProvider, constsProvider, CoverHelp, pathFactory){
      this.$element = $element;
      this.dataProvider = dataProvider;
      this.navProvider = navProvider;
      this.pathFactory = pathFactory;
      this.constsProvider = constsProvider;
      this.CoverHelp = CoverHelp;
 }

 pathCanvasProvider.prototype = {
     onEditModeChange: function (editMode, points, widgetId){
         this.navProvider.editMode = editMode;
         if (editMode != this.constsProvider.EDIT_MODE.PATH){
             //切回到编辑模式
             this.CoverHelp.hide();
             this.$element.removeClass('show');
             this.navProvider.disableCanvasSelectable = false;
             this.pathFactory.clearPoints();
         } else {
             //切换到PATH模式
             this.CoverHelp.show();
             this.$element.addClass('show');
             this.navProvider.disableCanvasSelectable = true;
             // clear points
             this.pathFactory.setWidgetId(widgetId);
             this.pathFactory.clearPoints();
             for (var i = 0; i < points.length; i++){
                 this.pathFactory.addPoint(points[i].x, points[i].y);
             }
         }
     },
     onDelKeyHandler: function (){
         this.pathFactory.deletePoint();
     }
 };

 module.exports = pathCanvasProvider;
